<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var num = prompt("请输入一个数字");
      function zhishu(num) {
        var flag = true; //设置一个变量，代表是一个质数
        for (var i = 2; i < num; i++) {
          if (num % i == 0) {
            flag = false; //不是一个质数
            return false;
          }
        }
        return true;
      }
      console.log(zhishu(num));
    </script>
  </body>
</html>
